<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <el-form ref="form" :inline="true" label-width="auto">
          <el-input
            v-model="query.name"
            placeholder="请输入任务名称"
            clearable
            size="small"
            style="width: 200px;"
            class="filter-item"
            @keyup.enter.native="toQuery"
          />
          <el-select v-model="query.status" style="width: 200px;" placeholder="请选择发布状态" class="filter-item" clearable>
            <el-option v-for="val in statusList" :key="val" :label="val" :value="val" />
          </el-select>
          <rrOperation :crud="crud" />
        </el-form>
      </div>
      <crudOperation show="" :permission="permission" />

    </div>
    <el-dialog
      append-to-body
      :close-on-click-modal="false"
      :before-close="crud.cancelCU"
      :visible.sync="crud.status.cu > 0"
      title="编辑批处理脚本调度配置"
      width="1000px"
    >
      <el-form :inline="true" label-width="150px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="运行状态" prop="moduleName">
              <el-select v-model="query.statu" placeholder="请选择" clearable>
                <el-option v-for="val in statusList1" :key="val" style="width:200px" :label="val" :value="val" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="调度间隔" prop="moduleName">
              <el-select v-model="query.list" placeholder="请选择" clearable>
                <el-option v-for="val in statusList2" :key="val" style="width:200px" :label="val" :value="val" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="日期表达式" prop="moduleName">
              <el-input v-model="form.moduleName" style="width:205px" placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="偏移小时" prop="moduleName">
              <el-input-number v-model="num" style="width:205px" :min="0" :max="24" @change="handleChange" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="权重数值" prop="moduleName">
              <el-input-number v-model="num1" style="width:205px" :min="1" :max="24" @change="handleChange" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否顺序执行" prop="moduleName">
              <el-select v-model="query.tim" placeholder="请选择" clearable style="width:200px">
                <el-option v-for="val in statusList3" :key="val" :label="val" :value="val" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="允许出现错误" prop="moduleName">
              <el-input-number v-model="num2" style="width:205px" :min="0" :max="24" @change="handleChange" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="同步类型" prop="moduleName">
              <el-select v-model="query.tiasd" placeholder="请选择" clearable style="width:200px">
                <el-option v-for="val in statusList4" :key="val" :label="val" :value="val" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div>
        <el-button type="info" @click="crud.cancelCU">取消</el-button>
        <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">保存</el-button>
      </div>
    </el-dialog>
    <el-table ref="table" :data="tableList" style="  width: 100%;" @select="handleSelection">
      <el-table-column type="selection" width="55" />
      <el-table-column prop="name" label="文件名称" />
      <el-table-column prop="router" label="文件路径" />
      <el-table-column prop="size" label="操作状态" />
      <el-table-column prop="status" label="发布状态" />
      <el-table-column prop="createTime" label="发布类型" />
      <el-table-column label="操作">
        <el-button size="mini" type="text" @click="packFlag = true">发布</el-button>
      </el-table-column>
    </el-table>
    <pagination :total="2" />
    <el-dialog append-to-body :close-on-click-modal="false" :before-close="packClose" :visible.sync="packFlag" title="版本注释" width="800px">
      <el-input
        v-model="textarea"
        type="textarea"
        :rows="10"
        placeholder="请输入内容"
      />
      <div slot="footer" class="dialog-footer">
        <el-button type="text" @click="packClose">取消</el-button>
        <el-button type="primary" @click="packClose">确认</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import CRUD, { presenter, header, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
// import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultCrud = CRUD({
  title: '作业发布',
  url: ''
})
export default {
  components: { crudOperation, rrOperation, pagination },
  mixins: [presenter(defaultCrud), header(), crud()],
  data() {
    return {
      num: 0,
      num1: 1,
      num2: 0,
      statusList: ['已发布', '待发布', '发布中'],
      statusList1: ['启用', '禁用'],
      statusList2: ['日', '月', '年'],
      statusList3: ['是', '否'],
      statusList4: ['全部', '同步类型'],
      tableList: [
        {
          name: '数据迁移',
          router: '/dataTransfer',
          size: '添加更新',
          status: '已发布',
          createTime: '本地'
        },
        {
          name: '数据变更',
          router: '/dataTransfer',
          size: '添加更新',
          status: '待发布',
          createTime: 'dataworks'
        },
        {
          name: '数据变更',
          router: '/dataTransfer',
          size: '添加更新',
          status: '待发布',
          createTime: '调度平台'
        }
      ],
      permission: {
        add: ['admin', 'publish:add'],
        edit: ['admin', 'publish:edit'],
        del: ['admin', 'publish:del']
      },
      form: {
        ip: '',
        details: ''
      },
      packFlag: false,
      textarea: ''
    }
  },
  methods: {
    handleSelection(ids) {
      this.crud.selections = ids
    },
    packClose() {
      this.packFlag = false
    },
    handleChange(value) {
      console.log(value)
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.el-input{
  width: 120px;
}
</style>
